<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>添加公告</title>
		<link rel="stylesheet" type="text/css" href="css/common.css" />
		<style>
			body {
				background: #Fff;
			}
			
			.overlay,
			.overlay select,
			.overlay .form-dropdown {
				width: 142px;
			}
			
			.form>form.block-form>div>input.radio {
				width: 12px;
				height: auto;
				vertical-align: -2px;
			}
		</style>
	</head>

	<body>
		<div class="form" style="padding:40px;">
			<input type="hidden" value="" class="productId" />
			<form class="block-form" id="commentForm">
				
				
				<div style="margin-top:0px;">
					<label><span class="red">*</span>公告标题：</label>
					<input type="text" class="pro_name" placeholder="请输入公告标题" name="noticename" id="noticename" />
				</div>
				<div>
					<label><span class="red">*</span>公告类型：</label>
					<div class="overlay">
						<!--这个是用来存放选中的select的值的-->
						<input type="hidden" value="" class="form-select-value catevalue" />
						<div class="dropdown">
							<button class="dropdown-toggle form-dropdown" type="button">
				                    <span class="value text-ellipsis pro_catevalue">请选择公告类型</span>
				                    <span class="caret"></span>
				            </button>
							<ul class="none">
								<li data-value='001'>全部</li>
								<li data-value='002'>系统公告</li>
								<li data-value='003'>活动通知</li>
								<li data-value='004'>平台消息</li>
							</ul>
						</div>
					</div>
					<input type="text" value="" class="form-select-value" name="catename" id="catename" style="visibility: hidden; width:0px;" />
				</div>

				<div>
					<label><span class="red">*</span>是否发布：</label>
					<input type="radio" class="radio" name="publish" value="1" checked="" /> 是 <input type="radio" class="radio" name="publish" value="2" /> 否
				</div>

				<div>
					<label><span class="red">*</span>是否置顶：</label>
					<input type="radio" name="zhiding" class="radio" value="1" checked="" /> 是 <input type="radio" name="zhiding" class="radio" value="2" /> 否
				</div>

				<div class="over-hidden">
					<label class="fl"><span class="red">*</span>公告内容：</label>
					<div class="editor-content fl" style="width:700px;">
						<script id="container" name="content" type="text/plain" style="width:700px;height:220px;"></script>
					</div>
					<input type="text" value="" class="form-select-value" name="noticeContent" id="noticeContent" style="visibility: hidden; width:0px;height:0px;" />
				</div>
				<div class="clearfix"></div>
				<div>
					<label class="hidden"><span class="red hidden">*</span>产品名称：</label>
					<input type="submit" value="保存" class="search-input-button" id="subButton" />
					<input type="button" value="取消" class="search-input-button bgblue" id="backButton" />
				</div>
			</form>
		</div>

		<script src="js/jquery-1.8.2.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/js.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/scroll/jquery.slimscroll.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/jquery.validate.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/messages_zh.min.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript" charset="utf-8" src="js/ueeditor/ueditor.config.js"></script>
		<script type="text/javascript" charset="utf-8" src="js/ueeditor/ueditor.all.js">
		</script>
		<!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
		<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
		<script type="text/javascript" charset="utf-8" src="js/ueeditor/lang/zh-cn/zh-cn.js"></script>

		<script>
			var ue;
			var index = parent.layer.getFrameIndex(window.name); /*获取窗口索引*/
            
            function submitSuccess(){
            	
            }
            
			 $.validator.setDefaults({
				submitHandler: function() {
					//这里放验证成功之后要执行的函数
					submitSuccess();
					parent.layer.close(index);
				}
			});
			
			
			$(function() {
				commonObj.checkinit();
				//富文本编辑器
				ue = UE.getEditor('container', {
					autoHeight: false
				});
				
				//表单提交验证
				validatorObj.addMethod();
				validatorObj.validate();

				//点击取消按钮
				$('#backButton').on('click', function() {
					parent.layer.close(index);
				});

			})
			var validatorObj = {
				'addMethod': function() {
					//这里是验证产品类型
					$.validator.addMethod("iscateEmpty", function(value, element) {
						if($('.catevalue').val()) {
							return true;
						} else {
							return false;
						}
					}, "<i class=\" icon icon_error_red \"></i>请选择公告类型");

					//这里是验证公告内容
					$.validator.addMethod("iscontentEmpty", function(value, element) {
						var con = ue.getContent();
						if(con) {
							return true;
						} else {
							return false;
						}
					}, "<i class=\" icon icon_error_red \"></i>请输入公告内容");
				},
				'validate': function() {
					$("#commentForm").validate({
						rules: {
							noticename: {
								required: true,
							},
							catename: {
								iscateEmpty: true,
							},
							noticeContent: {
								iscontentEmpty: true,
							},
						},
						messages: {
							noticename: {
								required: "<i class=\" icon icon_error_red \"></i>请输入公告标题",
							},
						},
						errorPlacement: function(error, element) {
							error.appendTo('<i class=\" icon icon_error_red \"></i>').appendTo(element.parent());
						},
					});
				}
			}

			
			 
		</script>

	</body>

</html>